# Python 2.6.4
# Project Euler, Problem 17
# Copyright 2010 Talha Zaman

digits = [0,3,3,5,4,4,3,5,5,4]
tens = [0,3,6,6,5,5,5,7,6,6]
teens = [0,6,6,8,8,7,7,9,8,8]

def letters(s):
    if len(s) == 1:
        return digits[int(s)]
    elif len(s) == 2:
        if s[0]!="1": return tens[int(s[0])] + digits[int(s[1])]
        elif s[0]=="1" and s[1] == "0": return 3
        else: return teens[int(s[1])]
    elif len(s) == 3:
        t = letters(s[1:])
        if t==0: return digits[int(s[0])] + 7
        else: return digits[int(s[0])] + 7 + 3 + t

total = 0
for i in range(1,1000):
    total += letters(str(i))

print total+11
